<?php
require("./world/model/Entity.abstract.php");

/**
 * Represents a single player.
 *
 * @author Mark Dohmen.
 */
final class Player extends Character {
	
	/**
 	 * The players #id.
 	 */
	private $id;
	
	/**
 	 * The players username.
 	 */
	private $username;
	
	/**
 	 * The players password.
 	 */
	private $password;
	
	/**
 	 * The players email address.
 	 */
	private $email;
	
	/**
 	 * The players gameData.
 	 */
	private $playerDefinition;
	
	/**
	 * Holds an instance of ActionSender.
	 */
	private $actionSender;
	
	/**
 	 * Class Constructor.
	 *
	 * @param $userData
 	 */
	final public function Player(PlayerDefinition $playerDefinition) {
		$this->playerDefinition = $playerDefinition;
		$this->actionSender = new ActionSender($this);
	}
	
	/**
 	 * Sets the user #id.
	 *
	 * @param $id
 	 */
	final public function setId(int $id) {
		$this->id = $id;	
	}
	
	/**
 	 * Gets the user #id.
	 *
	 * @return $id
 	 */
	final public function getId() {
		return (int) $this->id;	
	}
	
	/**
 	 * Sets the username.
	 *
	 * @param $username
 	 */
	final public function setUsername(string $username) {
		$this->username = $username;	
	}
	
	/**
 	 * Gets the username.
	 *
	 * @return $username
 	 */
	final public function getUsername() {
		return (string) $this->username;	
	}
	
	/**
 	 * Sets the password.
	 *
	 * @param $password
 	 */
	final public function setPassword(string $password) {
		$this->password = $password;	
	}
	
	/**
 	 * Gets the password.
	 *
	 * @return $password
 	 */
	final public function getPassword() {
		return (string) $this->password;	
	}
	
	/**
 	 * Sets the email.
	 *
	 * @param $email
 	 */
	final public function setEmail(string $email) {
		$this->email = $email;	
	}
	
	/**
 	 * Gets the email.
	 *
	 * @return $email
 	 */
	final public function getEmail() {
		return (string) $this->email;	
	}
	
	/**
 	 * Gets the user data.
	 *
	 * @return $playerDefinition
 	 */
	final public function getPlayerDefinition() {
		if ($this->playerDefinition instanceof PlayerDefinition) {
			return (object) $this->playerDefinition;
		}
		return NULL;
	}
	
	/**
	 * Returns an instance of 
	 * ActionSender.
	 *
	 * @return $actionSender
	 */
	final public function getActionSender() {
		if ($this->actionSender instanceof ActionSender) {
			return (object) $this->actionSender;
		}
		return NULL;
	}
}
?>